﻿<!DOCTYPE html>
<?php 
	$r=$_GET['r'];
	$id=explode('-',$r);
	if (isset($_GET["chan"])) {
		$chan=$_GET["chan"];
	}else{
		$chan="";
	}
	include_once '../conn/mysql.php';
	$res=sql("s", "product", "*", "where id='".$id[0]."'");
	$res1=sql("s", "user", "*", "where id='".$id[1]."'");
	$info1=firstrow($res1);
	$info=firstrow($res);
?>
<html><head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1,minimum-scale=1,user-scalable=no">
<meta content="telephone=no" name="format-detection">
<meta name="apple-touch-fullscreen" content="yes">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<title>订单信息</title>
<link href="/static/css/buy.css" type="text/css" rel="stylesheet">
<script language="javascript">
//检测用户名是否合法

function check_usr(obj){

 var objvalue = obj.value;

 var b=/^[a-zA-Z\d]\w{2,10}[a-zA-Z\d]$/;

 if (!b.test(objvalue)) {


  return false;

 }

}




function checkback(){

 var backvalue = null;

 if(xmlHttp.readyState==1)

 {document.getElementById('checkusr').innerHTML ="<font color='#ff0000'>检测中...</font>";}

 if (xmlHttp.responseText == 1) {                                                                   //check.php 没注册返回1，注册返回2

  backvalue = "<font color='#00c72e'>可以使用！</font>";

 }else {

  backvalue="<font color='#ff0000'>抱歉，已经被注册啦！</font>";

 }

 if (xmlHttp.readyState == 4) {

  document.getElementById('checkusr').innerHTML = backvalue;

 }

}







//判断密码输入是否合法，一个是长度，一个是没有特殊字符

function check_psw(obj){

 checkpsw=obj.value;

 if(checkpsw.length > 5 && checkpsw.length<21){

  document.getElementById("checkpsw").innerHTML = "<font color='#00c72e'>密码可以使用!</font>";

   }else {

  document.getElementById("checkpsw").innerHTML="<font color='#ff0000'>密码不符合长度要求!</font>";

 }

  var b=/^[a-zA-Z\d]\w{2,10}[a-zA-Z\d]$/;

 if (!b.test(checkpsw)) {

  document.getElementById('checkusr').innerHTML ="<font color='#ff0000'>密码有非法字符!</font>";

  return false;

 }else {

  document.getElementById("checkusr").innerHTML="<font color='#ff0000'>密码设置符合要求</font>";

 }




}




//判断两次密码输入是否一致

function check_repsw(obj1,obj2){

 var objvalue1=obj1.value;

 var objvalue2=obj2.value;

 

 if(objvalue1==objvalue2){

  document.getElementById("checkrepsw").innerHTML="<font color='#00c72e'>两次输入密码一致！</font>";

 }else {

  document.getElementById("checkrepsw").innerHTML="<font color='#ff0000'>两次输入的密码不一样!</font>";

 }

 }




 

//判断手机号码格式是否合法

function check_tel(obj){

 var objvalue=obj.value;

 var regx=/^(?:13\d|15\d|18[123456789])-?\d{5}(\d{3}|\*{3})$/;

 if(regx.test(objvalue)){

  document.getElementById("checktel").innerHTML="<font color='#00c72e'>手机号码输入正确！</font>";

 }else{

  document.getElementById("checktel").innerHTML="<font color='#ff0000'>请输入正确的手机号!</font>";

 }

}




 

//判断邮箱地址格式是否合法

function check_mail(obj){

 var strm=obj.value;

 var regm = /^[a-zA-Z0-9_-]+@[a-zA-Z0-9_-]+(\.[a-zA-Z0-9_-]+)+$/;//验证Mail的正则表达式,^[a-zA-Z0-9_-]:开头必须为字母,下划线,数字,

 if (!strm.match(regm))

 {
 	return 0;

 }

}



    function FormCheck()
    {
        if (check_usr(document.form1.userId)==false)
        {
            alert("用户名号必须填写")
            document.form1.userId.focus();
            return (false);
        }
        if (check_mail(document.form1.password)==false)
        {
            alert("密码必须填写")
            document.form1.password.focus();
            return (false);
        }
 
        if (document.form1.password.value!=document.form1.repassword.value) 
        {
            alert("密码和确认密码不一致")
            return (false);
        } 
	    if (document.form1.address.value=="")
        {
            alert("姓名必须填写")
            document.form1.user_name.focus();
            return (false);
        }
		
		
		
    }

 
</script>
</head>
<body>
<?php
	$suk=explode('-|-',gv($info,"suk"));
	$jg=explode('-|-',gv($info,"jg"));
	$fc=explode('-|-',gv($info,"fc"));
?>
<form id="form_buy" action="../control.php?oper=buy&chan=<?=$chan;?>" method="post">
<input type="hidden" name="sp_id" value="<?=$id[0];?>">
<input type="hidden" name="spm"  value="<?=gv($info,"name");?>">
<input type="hidden" name="jg" id="jg"  value="<?=$jg[1];?>">
<input type="hidden" name="fc"  id="fc" value="<?=$fc[1];?>">
<input type="hidden" name="suk"  id="suk" value="<?=$suk[1];?>">
<input type="hidden" name="tjr"  value="<?=gv($info1,"user");?>">
<input type="hidden" name="shangjia"  value="<?=gv($info1,"superior");?>">
<section class="item_sec">
	<div class="item_wrap rel">
		<img src="../uploade/<?=gv($info,"sptu");?>" height="70" width="70">
		<p class="item_tle ellipsis"><?=gv($info,"name");?></p>
		<p class="item_pay">货到付款并包邮</p>
		<ul class="sku_ul">
<?php 

	for ($i = 1; $i < count($suk); $i++) {
		echo '<li><a data-jg="'.$jg[$i].'" data-suk="'.$suk[$i].'" data-fc="'.$fc[$i].'">'.$suk[$i].'</a></li>';
	}
	
?>		
		</ul>
		<input type="hidden" name="item_sku_id" id="item_sku_id" value="">
		<p class="row">
<label>价　格 </label><input type="hidden" id="item_num" name="num" value="1" />
<span class="i_pri" id="item_price">￥<?=$jg[1];?></span>
		</p>
	</div>
	</div>
	</div>
</section>
<section class="item_sec">
	<div class="item_wrap add">
		<p class="row">
			<label for="name">收货人</label>
			<input required="required" id="name" name="name" class="block input" tabindex="1" type="text" value="" />
		</p>
		<p class="row">
			<label for="tel">联系手机</label>
			<input required="required" id="tel" name="tel" maxlength="11" class="block input" tabindex="2" type="tel" value="" />
		</p>
		<p class="row">
			<label for="province">选择地区</label>
			<select class="select" id="province" name="province" tabindex="3">
			</select><select class="select" id="city" name="city" tabindex="4">
			</select><select class="select" id="area" name="area" tabindex="5">
			</select>
		</p>
		<p class="row row_area">
			<label for="address">详细地址</label>
			<input required="required" id="address" name="xdz" class="block input" placeholder="街道门牌信息" tabindex="6" type="text" value="">
		</p>
	<p class="row row_area">
			<label>推荐人</label>
			<input class="block input" tabindex="7" type="text" readonly value="<?=gv($info1,"user");?>">
		</p> 	
		</div>
</section>
<footer>
	<button type="button" class="c_txt orange_bg"   id="buy_now">提交订单</button>
</footer>
</form>
<script src="/static/js/base_H5.js"></script>
<script src="/static/js/PCASClass.js"></script>
<script>
var pcas = new PCAS("province,省份","city,城市","area,地区");
var Item = {
	getItemInfo : function(){
		
	},
	changeCount : function(){
		$("#name").bind("focusout",function(){
			var _this = $(this);
			var val = _this.val();
			if(1!=1){
				alert("用户不可为空");
				_this.val(1);
				return;
			}
			
		})
	},
	init : function(){
		
		$("#buy_now").bind("click", function() {
			
			var name=$("#name").val();
			var tel=$("#tel").val();
			var adress=$("#address").val();
			var pro=$("#province").val();
			if(name==''){
				alert("用户不可为空");
				return;
				}else if(tel==''){
					alert("电话不可为空");
				return;
					}else if(adress==''){
					alert("地址不可为空");
				return;
					}else if(pro==''){
					alert("地址不可为空");
				return;
					}else{
				$(this).attr("disabled", "disabled");
				Item.changeCount();
				Item.getItemInfo();
			document.getElementById("form_buy").submit();
			}
		});
	}
}
$(".sku_ul a").bind("click",function(){//尺码点击
			var o = $(this);
			if(!o.hasClass("sku_cur")){//点击的不是当前已经选中的
				$(".sku_cur").removeClass("sku_cur");
				o.addClass("sku_cur");
				/*更新对应的选中尺码的数据*/
				$("#item_price").html("￥"+ o.attr("data-jg"));
				$("#item_num").val(o.attr("data-jg"));
				$("#suk").val(o.attr("data-suk"));
				$("#fc").val(o.attr("data-fc"));
				$("#jg").val(o.attr("data-jg"));
			}
		})
Item.init();
</script>
</body>
</html>